<?php 
//include  "./../protected.php"; /*Valida el inico de sesion*/
?>
<!doctype html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <title>Agregar académicos</title>
   <!--<link rel="stylesheet" type="text/css" href="mtb.css"/>
  <link rel="stylesheet" type="text/css" href="main.css"/>-->
  <link rel="stylesheet" type="text/css" href="ceGrid.css"/>
  <link rel="stylesheet" type="text/css" href="../bootstrap.css"/>
  <script type="text/javascript" src="../../../js/jquery.js"></script>
  <link rel="stylesheet" type="text/css" href="../../../css/index.css" />
  <script>

   
    function soloLetras(e){
       key = e.keyCode || e.which;
       tecla = String.fromCharCode(key).toLowerCase();
       letras = " áéíóúabcdefghijklmnñopqrstuvwxyz";
       especiales = "8-37-39-46";

       tecla_especial = false
       for(var i in especiales){
            if(key == especiales[i]){
                tecla_especial = true;
                break;
            }
        }

        if(letras.indexOf(tecla)==-1 && !tecla_especial){
            return false;
        }
    }
</script>
  
  
</head>

<!-------------------------------------------------------------------------->
<body>
<br />
<br />
<br />
<br />
	<div id="content-mt">
		<form class="form-horizontal" name="Reg_academico" method="POST" id="form-pro" action="insert.php" class="style">
<fieldset>
<!-- Form Name -->
<legend>Registro del Responsable</legend>

<!-- Text input-->
<div class="form-group">
  <label for="textinput">Identificación</label>  
  <input  name="id" id="id" type="text"  placeholder="Ingrese la indentificación"class="form-control input-md" maxlength="50" required>
  </div>

<!-- Text input-->
<div class="form-group">
  <label for="textinput">Nombre</label>  
  <input name="nombre" id="nombre" type="text"  placeholder="Ingrese el nombre "class="form-control input-md" onkeypress="return soloLetras(event)" required>
  </div>


<!-- Text input-->
<div class="form-group">
  <label for="textinput">Primer Apellido</label>  
  <input name="apelli1" id="apelli1" type="text" placeholder="Ingrese el Primer Apeliido" class="form-control input-md" onkeypress="return soloLetras(event)" required>
  </div>


<!-- Text input-->
<div class="form-group">
  <label for="textinput">Segundo Apellido</label>  
  <input name="apelli2" id="apelli2" type="text" placeholder="Ingrese el Segundo Apellido"class="form-control input-md"onkeypress="return soloLetras(event)" required>
  </div>

<div class="form-group">
<label>Responsable</label>
<SELECT  name="tipo" id="tipo" required  class="form-control input-md" >
<option value ="">Seleccione una Opción...</option>
<?php 
$conexion=mysql_connect("localhost","root","root") or
die("Problemas en la conexion");
mysql_select_db("ga",$conexion) or
die("Problemas en la selección de la base de datos");  
$clavebuscadah=mysql_query("SELECT `GA05IDTR`,`GA05NOTR`,`GA05A1TR`,`GA05A2TR` FROM `ga`.`ga05tpresp`
                            ORDER BY GA05NOTR; ",$conexion) or
die("Problemas en el select:".mysql_error());
while($row = mysql_fetch_array($clavebuscadah))
{
echo'<OPTION VALUE="'.$row['GA05IDTR'].'">'.$row['GA05NOTR'].' '.$row['GA05A1TR'].' '.$row['GA05A2TR'].'</OPTION>';
}
 
?>
</SELECT>

<!-- Button -->
<div class="form-group">
<button type="submit" name="Agregar_Btn" class="btn" onclick="pregunta()"  id="Agregar_Btn">Agregar</button>
<a class="btn" href="index.php">Lista de Responsables</a>
</div>
<hr />
</fieldset>
</form>
		<!--<form name="Reg_academico" method="POST" id="form-pro" action="insert.php" class="style" > 

<div id="div01"  class="curved" >
<table id = "tab01">
<div id="error"></div>
	<tr align="center">
	<td>Identificación</td>
              <td><label>
            <input type="text" name="id" id="id" value = ""  maxlength="40"  /> 
         
            </label></td>
       </tr>
        <tr>
          <td>Nombre</td>
            <td><label>
                <input type="text" name="nombre" id="nombre" placeholder="Ingrese el nombre" value = "" maxlength="50"  onkeypress="return soloLetras(event)"/> 
         
              </label></td>
       </tr>
    <tr>
            <td>Primer apellido</td>
              <td><label>
            <input type="text" name="apelli1" id="apelli1" value = ""  maxlength="40" onkeypress="return soloLetras(event)" /> 
         
            </label></td>
       </tr>

      <td>Segundo apellido</td>
              <td><label>
            <input type="text" name="apelli2" id="apelli2" value = ""  maxlength="40" onkeypress="return soloLetras(event)" /> 
         
            </label></td>
       </tr>
       <tr>
       <td width="500" align="left"><label>Responsable:</label>
                      <select name="tipo" id="tipo" required>
                          <option value="0">Seleccionar</option>
                          <?php
                         require '../GestionPermisos/config/conn.php';
                          // Preparamos la consulta.
                          $result = $conectarBD->query("SELECT GA05IDTR,GA05NOTR, GA05A1TR, GA05A2TR FROM ga05tpresp ORDER BY GA05NOTR")or die($mysqli->error);
                          ?>
                          <?php while($row = $result->fetch_assoc()){ ?>
                          <option value="<?php echo $row['GA05IDTR']; ?>"><?php echo "".$row['GA05NOTR']." ".$row['GA05A1TR']." ".$row['GA05A2TR']." Cédula:".$row['GA05IDTR']; ?></option>
                          <?php }
                          mysqli_free_result($sql);
                          ?>
                      </select>
                    </td>
         <td></td>
         <td><label>
         <input type="submit" name="Agregar_Btn" class="btn-m"  id="Agregar_Btn" value="Agregar" />
         </label></td>
     </tr>
     </tr>
</table> 
 </form>-->
</div>
</div>
</body>
<!--script de validacion formulario-->
<script type="text/javascript">
    $(function(){
    
         $("#id").focus();
    $("#form-pro").submit(function(e){
        e.preventDefault();
    var form_data= {    
           datos:$("#id").val(),
           

        };
        
         $.ajax({
          type: "POST",
          url: "insert.php",
                   data: data1, // Adjuntar los campos del formulario enviado.
                   success: function(data)
                   {
                    $("#error").html(data);
                   }
               });
            return false; // Evitar ejecutar el submit del formulario.
        });
      });
    function pregunta(){ 
    if (confirm('¿Estas seguro de enviar este formulario?')){ 
       document.tuformulario.submit() 
    } 
}
</script>
</html>

